<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title></title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="{__STATIC_PATH}layuiadmin/layui/css/layui.css" media="all">
    <script src="{__STATIC_PATH}/layuiadmin/layui/layui.js"></script>
    <script>
        layui.config({
            base: '{__STATIC_PATH}layuiadmin/' //静态资源所在路径
        })
    </script>
</head>
<body>
<div class="layui-form" lay-filter="layuiadmin-app-form-list" id="layuiadmin-app-form-list" style="padding: 20px 30px 0 0;">
    <input type="hidden" name="id" value="{$arr_data_info['id']}">
    <div class="layui-form-item">
        <label class="layui-form-label">权限名称</label>
        <div class="layui-input-inline">
            <input type="text" name="name" lay-verify="required" value="{$arr_data_info['name']}" placeholder="请输入权限名称" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">URL地址</label>
        <div class="layui-input-inline">
            <input type="text" name="url" lay-verify="" value="{$arr_data_info['url']}" placeholder="请输入URL地址" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">权重</label>
        <div class="layui-input-inline">
            <input type="text" name="order_num" lay-verify="required" value="{$arr_data_info['order_num']}" placeholder="请输入权重" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">状态</label>
        <div class="layui-input-inline">
            <input type="checkbox" name="is_lock" lay-skin="switch" lay-text="开启|关闭" value="1" {$arr_data_info['is_lock']==1?'checked':''}>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">图标</label>
        <div class="layui-input-inline">
            <input type="text" name="icon" lay-verify=""  value="{$arr_data_info['icon']}" placeholder="请输入图标" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">父级</label>
        <div class="layui-input-inline">
            <select name="pid" lay-verify="">
                <option value="0">一级菜单</option>
                <?php echo $str_option_html;?>
            </select>
        </div>
    </div>
    <div class="layui-form-item layui-hide">
        <input type="button" lay-submit lay-filter="layuiadmin-app-form-submit" id="layuiadmin-app-form-submit" value="确认添加">
    </div>
</div>
<script>
    layui.extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'form'], function(){
        var $ = layui.$,form = layui.form;
        var admin = layui.admin;
        //监听提交
        form.on('submit(layuiadmin-app-form-submit)', function(data){
            var field = data.field; //获取提交的字段
            var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
            //提交 Ajax 成功后，关闭当前弹层并重载表格
            admin.req({
                url: "/admin/rbac/authEdit"
                ,type: "POST"
                ,data: field
                ,datatype:'json'
                ,success: function(res){
                    if (res.code == 0) {
                        layer.msg('操作成功',{time:500},function(){
                            parent.layui.table.reload('table-list'); //重载表格
                            parent.layer.close(index); //再执行关闭
                        });
                    }
                    else {
                        layer.msg(res.msg);
                    }
                }
            });
            // $.ajax({
            //     dataType:'json',
            //     type: "POST",
            //     url: "/admin/rbac/authEdit",
            //     data: field,
            //     success: function (Data) {
            //         if (Data.code == 0) {
            //             layer.msg('操作成功',{time:500},function(){
            //                 parent.layui.table.reload('table-list'); //重载表格
            //                 parent.layer.close(index); //再执行关闭
            //             });
            //         }
            //         else {
            //             layer.msg(Data.msg);
            //         }
            //     },
            //     error: function () {
            //         alert("出现错误");
            //         return false;
            //     }
            // }) //ajax结束
        });
    })
</script>
</body>
</html>